package com.atguigu.DAO.impl;

import com.atguigu.pojo.OrderItem;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class OrderItemDaoImple extends BaseDAO implements OrderItemDao {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        System.out.println("saveOrderItem程序在["+Thread.currentThread().getName()+"]中");

        String sql="insert into t_order_item(`name`,`count`,`price`,`total_price`,`order_id`) values(?,?,?,?,?)";
        return update(sql,orderItem.getName(),orderItem.getCount(),orderItem.getPrice(),orderItem.getTotalPrice(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemByOrderId(String orderId) {
        String sql="SELECT id,`name`,`count`,price,total_price totalPrice FROM t_order_item WHERE order_id=?";
        return queryForList(OrderItem.class,sql,orderId);
    }
}
